﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Common;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace DSAAssignment.Models
{
    public class Register
    {
        [Required(ErrorMessage = "Username is required")]
        [Remote("DoesUsernameExists", "User", ErrorMessage = "Username already registered!")]
        public string Username { get; set; }

        [Required(ErrorMessage = "Password is required")]
        public string Password { get; set; }

        [Required(ErrorMessage = "Email is required")]
        [DataType(DataType.EmailAddress, ErrorMessage = "Incorrect Email format!")]
        [RegularExpression(@"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}", ErrorMessage = "Please enter correct email!")]
        [Remote("DoesEmailExists", "User", ErrorMessage = "Email already registered!")]
        public string Email { get; set; }

        [Required(ErrorMessage = "Name is required")]
        public string Name { get; set; }

        [Required(ErrorMessage = "Surname is required")]
        public string Surname { get; set; }

        [Required(ErrorMessage = "House Number is required")]
        public int HouseNo { get; set; }

        [Required(ErrorMessage = "Street Name is required")]
        public string StreetName { get; set; }

        [Required(ErrorMessage = "Town is required")]
        public string TownName { get; set; }

        [Required(ErrorMessage = "Country is required")]
        public int Country { get; set; }

        public SelectList CountryList { get; set; }

        [Required(ErrorMessage = "Mobile No is required")]
        public int MobileNo { get; set; }

        public Register()
        {
            CountryList = new SelectList(new UserServ.UserServicesClient().GetCountries(), "ID", "CountryName");
        }
    }
}